﻿Public Class calc
   Const dEekEur As Double = 15.6466
   Private bWorking As Boolean

   Private Sub txtEUR_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtEUR.TextChanged
      If Not bWorking Then
         bWorking = True
         txtEEK.Text = fToEEK(txtEUR.Text)
         bWorking = False
      End If
   End Sub

   Private Sub txtEEK_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtEEK.TextChanged
      If Not bWorking Then
         bWorking = True
         txtEUR.Text = fToEUR(txtEEK.Text)
         bWorking = False
      End If
   End Sub

   Function fToEEK(ByVal sVal As String) As Double
      If Not IsNumeric(sVal) Then
         Return 0
      Else
         Dim dVal As Double = Val(sVal) * dEekEur
         Return Math.Round(dVal, 2)
      End If
   End Function
   Function fToEUR(ByVal sVal As String) As Double
      If Not IsNumeric(sVal) Then
         Return 0
      Else
         Dim dVal As Double = Val(sVal) / dEekEur
         Return Math.Round(dval, 2)
      End If
   End Function
End Class
